//215
class Solution {
    public int findKthLargest(int[] nums, int k) {
        int len = nums.length;
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        for (int i = 0; i < len; i++) {
            if (i >= k) {
                if (priorityQueue.peek() < nums[i]) {
                    priorityQueue.poll();
                    priorityQueue.add(nums[i]);
                }
            }
            else {
                priorityQueue.add(nums[i]);
            }
        }
        return priorityQueue.peek();
    }
}

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);        
            String str = in.nextLine();

            int a = str.lastIndexOf(' ');
            String s = str.substring(a + 1);
            System.out.println(s.length());
        
    }
}

class Solution {
    public boolean isPalindrome(String s) {
        s = s.toLowerCase();
        int i = 0;
        int j = s.length() - 1;
        while(i < j){
            while(i < j && !isNumOrCharacter(s.charAt(i))){
                i++;
            }
            if (!(i < j)){
                break;
            }

            while(i < j && !isNumOrCharacter(s.charAt(j))){
                j--;
            }
            if (!(i < j)){
                break;
            }

            if (s.charAt(i) != s.charAt(j)){
                return false;
            }
            i++;
            j--;
        }
        return true;
    }
    public boolean isNumOrCharacter(char ch) {
        if(ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z') {
            return true;
        }
        return false;
    }
}
//DP34

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
            int n = in.nextInt();
            int q = in.nextInt();
            long[] arr = new long[n];
            arr[0] = in.nextLong();
            for (int i = 1; i < n; i++) {
                arr[i] = arr[i-1] + in.nextLong();
            }
            for (int i = 0; i < q; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                if (a-2 >= 0) {
                    System.out.println(arr[b-1] - arr[a-2]);
                } 
                else {
                    System.out.println(arr[b-1]);
                }
                
            }
        
    }
}

